package com.woniu40.petai_manager.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu40.petai_manager.entity.User;
import com.woniu40.petai_manager.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    UserMapper userMapper;

    public PageInfo<User> findUsers(Integer pageNum,Integer pageSize,String name){
        PageHelper.startPage(pageNum,pageSize);
        List<User> users = userMapper.selectAll(name);
        PageInfo<User> userPageInfo = new PageInfo<>(users);
        return userPageInfo;
    }

    public int update(Integer userid){
        int i = userMapper.selectStatusByUserId(userid);
        int update = userMapper.update(userid, i);
        return update;
    }



}
